﻿using CoreWf;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace netcoreWF
{
    public sealed class DelayActivity : CodeActivity<bool>
    {
        // Define an activity input argument of type string
        public InArgument<string> Text { get; set; }

        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override bool Execute(CodeActivityContext context)
        {
            bool argumented = false;
            string textValue = Text.Get(context);
            if (textValue != null)
            {
                Task.Delay(TimeSpan.FromSeconds(Int32.Parse(textValue)));
                Console.WriteLine("delay");
                argumented = true;
            }
            else
            {
                Task.Delay(TimeSpan.FromSeconds(1));
            }

            return argumented;
        }
    }
}
